home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Book Chapters / 10 - Networking / NovelNetwar / menus.c < prev    next >
Text File  |  1995-05-12  |  3KB  |  167 lines

  1. //    Menu handling stuff.
  2.  
  3. #include "NovelNetwar.h"
  4.  
  5.  
  6. #define NUMMENUS    5
  7.  
  8. #define appleMenu        0
  9. #define    fileMenu        1
  10. #define    editMenu        2
  11. #define    playMenu        3
  12. #define    reinforceMenu    4
  13.  
  14.  
  15. #define    appleID            128
  16. #define    fileID            129
  17. #define    editID            130
  18. #define    playID            131
  19. #define    reinforceID        132
  20.  
  21.  
  22. #define aboutMe            1
  23. #define    helpCommand        2
  24.  
  25. #define quitCommand        1
  26.  
  27. #define undoCommand         1
  28. #define cutCommand            3
  29. #define copyCommand            4
  30. #define pasteCommand        5
  31. #define clearCommand        6
  32. #define    selectAllCommand    7
  33.  
  34.  
  35. #define    instructionsCommand    1
  36. #define    UNCommand            3
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43. static    MenuHandle        myMenus[NUMMENUS];
  44.  
  45.  
  46.  
  47.  
  48.  
  49. void menusInit(void)
  50. {
  51.  
  52. }
  53.  
  54.  
  55. void menusStartup(void)
  56. {
  57.     myMenus[appleMenu] = GetMenu(appleID);
  58.     AddResMenu(myMenus[appleMenu],'DRVR');
  59.     myMenus[fileMenu] = GetMenu(fileID);
  60.     myMenus[editMenu] = GetMenu(editID);
  61.     myMenus[playMenu] = GetMenu(playID);
  62.  
  63.     InsertMenu(myMenus[appleMenu],0);
  64.     InsertMenu(myMenus[fileMenu],0);
  65.     InsertMenu(myMenus[editMenu],0);
  66.     InsertMenu(myMenus[playMenu],0);
  67.     
  68.     DrawMenuBar();
  69. }
  70.  
  71.  
  72.  
  73. void menusShutDown(void)
  74. {
  75.  
  76. }
  77.  
  78.  
  79.  
  80.  
  81. OSErr DoCommand(long mResult)
  82. {
  83. int            theItem,i;
  84. WindowPeek     wPtr;
  85. GrafPtr        oldPort;
  86. char        tempString[256];
  87.  
  88.     theItem = LoWord(mResult);
  89.     
  90.     switch (HiWord(mResult)) 
  91.     {
  92.         case appleID:
  93.             if (theItem == aboutMe)
  94.             {
  95.                 DoAboutBox(0);
  96.             }
  97.             
  98.             else if (theItem == helpCommand)
  99.             {
  100.                 DoHelpBox(HELPWIND,HELPTEXT,HELPSTYL);
  101.             }
  102.                 
  103.             else
  104.             {
  105.                 InitCursor();
  106.                 GetItem(myMenus[appleMenu], theItem,(unsigned char *) tempString);
  107.                 OpenDeskAcc((unsigned char *) tempString);
  108.             }
  109.             
  110.             break;
  111.             
  112.         case fileID:
  113.             switch (theItem)
  114.             {
  115.                 case quitCommand:
  116.                     alive = FALSE;
  117.                     break;
  118.             }
  119.             
  120.             break;
  121.         
  122.         case editID:
  123.             SystemEdit(theItem - 1);
  124.             
  125.             break;
  126.         
  127.         case playID:
  128.             switch (theItem)
  129.             {
  130.                 case instructionsCommand:
  131.                     DoHelpBox(HELPWIND,HELPTEXT,HELPSTYL);
  132.                     
  133.                     break;
  134.             }
  135.             
  136.             break;
  137.         
  138.         default:
  139.             break;
  140.     }
  141.     
  142.     HiliteMenu(0);
  143. }
  144.  
  145.  
  146.  
  147.  
  148. void DisableEditMenu(void)
  149. {
  150.     DisableItem(myMenus[editMenu],undoCommand);
  151.     DisableItem(myMenus[editMenu],cutCommand);
  152.     DisableItem(myMenus[editMenu],copyCommand);
  153.     DisableItem(myMenus[editMenu],clearCommand);
  154.     DisableItem(myMenus[editMenu],pasteCommand);
  155.     DisableItem(myMenus[editMenu],selectAllCommand);
  156. }
  157.  
  158.  
  159. void EnableEditMenu(void)
  160. {
  161.     EnableItem(myMenus[editMenu],undoCommand);
  162.     EnableItem(myMenus[editMenu],cutCommand);
  163.     EnableItem(myMenus[editMenu],copyCommand);
  164.     EnableItem(myMenus[editMenu],clearCommand);
  165.     EnableItem(myMenus[editMenu],pasteCommand);
  166.     EnableItem(myMenus[editMenu],selectAllCommand);
  167. }